package name.tp.listener;

import lombok.extern.slf4j.Slf4j;
import name.tp.modules.bom.service.BomServiceI;
import org.springframework.batch.core.ItemWriteListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Created by Tp-wangwh on 2019-10-31.
 */
@Service
@Slf4j
public class MybatisItemWriteListener implements ItemWriteListener {
    @Autowired
    private BomServiceI bomServiceI;
    @Override
    public void beforeWrite(List items) {

    }

    @Override
    public void afterWrite(List items) {

    }

    @Override
    public void onWriteError(Exception exception, List items) {
        //TODO 记录失败的条数据
        log.error("插入数据失败:"+items.size()+","+exception.toString());
        bomServiceI.insertFailItem(items,exception.toString());
    }
}
